//
//  XKNewsCell.m
//  XKJF
//
//  Created by Jack on 2016/12/26.
//  Copyright © 2016年 xiaokang100. All rights reserved.
//

#import "XKNewsCell.h"

@interface XKNewsCell ()

@property(nonatomic, strong) UILabel        *newsTitleLab;
@property(nonatomic, strong) UIImageView    *timeImgView;
@property(nonatomic, strong) UILabel        *timeLab;
@property(nonatomic, strong) UIView         *bottomLineView;

@end
@implementation XKNewsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addSubviews];
    }
    return self;
}

- (void)addSubviews {
    
    self.newsTitleLab = [UILabel getLabWithText:@"--" textFont:Font_15];
    self.newsTitleLab.textColor = BlackColor;
    
    self.timeImgView = [UIImageView new];
    self.timeImgView.image = [UIImage imageNamed:@"infor_con_icon_time"];
    
    self.timeLab = [UILabel getLabWithText:@"--" textFont:Font_12 textColor:GrayColor];
    
    
    
    self.bottomLineView = [UIView new];
    self.bottomLineView.backgroundColor = kBaseGrayColor;
    
    
    
    [self.contentView addSubview:self.newsTitleLab];
    [self.contentView addSubview:self.timeImgView];
    [self.contentView addSubview:self.timeLab];
    [self.contentView addSubview:self.bottomLineView];
    
    
    [self.newsTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(10*Scale_W);
        make.right.mas_equalTo(self.contentView).offset(-10*Scale_W);
        make.top.mas_equalTo(self.contentView).offset(10*Scale_H);
    }];
    
    [self.timeImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.newsTitleLab);
        make.top.mas_equalTo(self.newsTitleLab.mas_bottom).offset(20*Scale_H);
        make.size.mas_equalTo(CGSizeMake(10*Scale_W, 10*Scale_W));
    }];
    
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.timeImgView.mas_right).offset(5*Scale_W);
        make.centerY.mas_equalTo(self.timeImgView);
    }];
    
    
    [self.bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(self.contentView).priorityHigh();
        make.top.mas_equalTo(self.timeImgView.mas_bottom).offset(10*Scale_H);
        make.height.mas_equalTo(1*Scale_H);
    }];
}




- (void)setModel:(Data *)model {
    _model = model;
    _newsTitleLab.text = model.title;

//    _timeLab.text = [NSString getTimeStringWithTimestamp:model.add_time.integerValue];;
     _timeLab.text = [NSString intervalSinceNowFrome:model.add_time.integerValue];
}

@end
